//获取平台属性的接口函数

//导入二次封装axios
import request from "@/utils/request";
import type { AttrList, GetAttrListApiParams, AttrItem } from "./models/attrModel";

//枚举接口地址
enum Api {
  getAttrListUrl = "/admin/product/attrInfoList",
  addAttrUrl = "/admin/product/saveAttrInfo",
  deleteAttr = "/admin/product/deleteAttr",
}

/**
 * 获取平台属性的接口函数
 * @param param0
 * @returns  AttrList
 */
export const getAttrListApi = ({ category1Id, category2Id, category3Id }: GetAttrListApiParams) => {
  return request.get<any, AttrList>(Api.getAttrListUrl + `/${category1Id}/${category2Id}/${category3Id}`);
};

/**
 * 添加属性的接口函数
 * @param attrInfo
 * @returns null
 */
export const addAttrApi = (attrInfo: AttrItem) => {
  return request.post<any, null>(Api.addAttrUrl, attrInfo);
};

/**
 * 删除属性的接口函数
 * @param id
 * @returns null
 */
export const deleteAttrApi = (id: number) => {
  return request.delete<any, null>(`${Api.deleteAttr}/${id}`);
};
